<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>限流函数</title>
    <script src="https://unpkg.com/vue@next"></script>
  </head>
  <body>
    <div id="Application">
      <button @click="click">按钮</button>
    </div>
  </body>

  <script>
    var throttle=false
    function throttleTool(callback, timeout){
      if(!throttle){
        callback()
      }else{
        return;
      }
      throttle = true;
      setTimeout(()=>{
        throttle = false
      },timeout)
    }


    const App= {
      data(){
        return {
          throttle:false
        }
      },
      methods: {
        click(){
            throttleTool(()=>{
              console.log(Date())
            }, 2000)
        }
      }
    }
    Vue.createApp(App).mount("#Application")
  </script>

</html>